<?php

use common\models\Blog;
use common\models\Category;
use kartik\datetime\DateTimePicker;
use yii\helpers\Html;
use yii\redactor\widgets\Redactor;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model backend\models\Blog */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="blog-form">

    <?php $form = ActiveForm::begin(); ?>

    <!-- $form->field($model, 'id')->textInput()-->

    <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>

    <!--$form->field($model, 'content')->textarea(['rows' => 6])-->
    <?= $form->field($model, 'content')
        ->widget(Redactor::className(), [
            'clientOptions' => [
                'imageManagerJson' => ['/redactor/upload/image-json'],
                'imageUpload' => ['/redactor/upload/image'],
                'fileUpload' => ['/redactor/upload/file'],
                'lang' => 'zh_cn',
                'plugins' => ['clips', 'fontcolor', 'imagemanager']
            ]
        ]) ?>

    <?= $form->field($model, 'is_delete')
        ->dropDownList(Blog::dropDownList()) ?>
    <?= $form->field($model, 'category')
        ->label('栏目')
        ->checkboxList(Category::dropDownList()) ?>

    <!--$form->field($model, 'created_at')->textInput()-->
    <!--  = $form->field($model, 'created_at')->widget(DateTimePicker::className(), [
        'options' => [
            'placeholder' => '请选择时间',
            // 默认时间
            'value' => date("Y-m-d H:i:s"),
        ],
        'pluginOptions' => [
            'autoclose' => true,
            'todayHighlight' => true
        ]
    ])
    <!--$form->field($model, 'updated_at')->textInput()-->
    <!--    echo '<label>更新时间</label>';
        echo DateTimePicker::widget([
            'name' => 'Blog[updated_at]',
            'options' => ['placeholder' => '情输入更新时间'],
            //注意，该方法更新的时候你需要指定value值
            'value' => date("Y-m-d H:i:s"),
            'pluginOptions' => [
                'autoclose' => true,
                'format' => 'yyyy-mm-dd HH:ii:ss',
                'todayHighlight' => true
            ]
        ]);

        -->

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? '添加' : '更新', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
